<!--
 * @Author: 一品网络技术有限公司
 * @Date: 2022-09-26 16:22:44
 * @LastEditTime: 2022-09-26 22:10:48
 * @FilePath: \ypcmsvue3\src\pages\permissions\admin\view.vue
 * @Description:
 * 联系QQ:58055648
 * Copyright (c) 2022 by 东海县一品网络技术有限公司, All Rights Reserved.
-->
<template>
    <div class="bg-white w-full select-none rounded-lg" v-if="isLoad">
        <div>
            <component :is='componentId' :r="r" @edit="edit"></component>
        </div>
    </div>
</template>
<script setup>
import store from '@/store'
import { onMounted, ref, reactive, shallowRef } from 'vue'
import { getData } from '@/common/base'
import Profile from './profile.vue'
import EditProfile from './editProfile.vue'
const isLoad = ref(false)
const r = ref([])
const adminId = store.state.admin.id
const fromParam = reactive({})
const componentId = shallowRef(Profile)
const edit = (t) => {
    if (t == 'edit') {
        componentId.value = EditProfile
    } else {
        componentId.value = Profile
        getUser()
    }

}

const getUser = async () => {
    const resp = await getData('/admin/read', { id: adminId })
    if (resp.code == 1) {
        r.value = resp.data
        Object.keys(resp.data).map((k) => {
            fromParam[k] = resp.data[k]
        })
    }


}


onMounted(() => {
    getUser()
    isLoad.value = true
})
</script>
